<?php

class Application_Model_Uzytkownicy {

    protected $_id_uzytkownika;
    protected $_haslo;
    protected $_imie;
    protected $_nazwisko;
    protected $_adres;
    protected $_miasto;
    protected $_rola;
    
    public function __construct(array $options = null) {
        if (is_array($options)) {
            $this->setOptions($options);
        }
    }

    public function __set($name, $value) {
        $metoda = 'set' . ucfirst($name);

        if (('mapper' == $name) || !method_exists($this, $metoda)) {
            throw new exception('Nie ma takiej wĹ‚aĹ›ciwoĹ›Ä‡i!');
        }

        $this->$metoda($value);
    }

    public function __get($name) {
        $metoda = 'get' . ucfirst($name);

        if (('mapper' == $name) || !method_exists($this, $metoda)) {
            throw new exception('Nie ma takiej wĹ‚aĹ›ciwoĹ›Ä‡i!');
        }

        $this->$metoda();
    }

    public function setOptions(array $options) {
        $methods = get_class_methods($this);

        foreach ($options as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (in_array($method, $methods)) {
                $this->$method($value);
            }
        }
        return $this;
    }

    public function setIdUzytkownika($id) {
        $this->_id_uzytkownika = (int) $id;
        return $this;
    }

    public function getIdUzytkownika() {
        return $this->_id_uzytkownika;
    }

    public function setHaslo($haslo) {
        $this->_haslo = (string) $haslo;
        return $this;
    }

    public function getHaslo() {
        return $this->_haslo;
    }

    public function setImie($imie) {
        $this->_imie = (string) $imie;
        return $this;
    }

    public function getImie() {
        return $this->_imie;
    }

    public function setNazwisko($nazwisko) {
        $this->_nazwisko = (string) $nazwisko;
        return $this;
    }

    public function getNazwisko() {
        return $this->_nazwisko;
    }

    public function setAdres($adres) {
        $this->_adres = (string) $adres;
        return $this;
    }

    public function getAdres() {
        return $this->_adres;
    }

    public function setRola($rola) {
        $this->_rola = (string) $rola;
        return $this;
    }

    public function getRola() {
        return $this->_rola;
    }

    public function setMiasto($miasto) {
        $this->_miasto = (string) $miasto;
        return $this;
    }

    public function getMiasto() {
        return $this->_miasto;
    }
    

}

